package com.zjun.demo.experimentaldemo.lifecycle

import android.content.Context
import androidx.lifecycle.ViewModelProvider
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.zjun.demo.experimentaldemo.R
import com.zjun.demo.experimentaldemo.databinding.FragmentBlankBinding

class BlankFragment : Fragment() {

    private lateinit var binding:FragmentBlankBinding
    companion object {
        fun newInstance() = BlankFragment()
    }

    private lateinit var viewModel: BlankViewModel


    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View {
        binding = DataBindingUtil.inflate(inflater,R.layout.fragment_blank,container,false)
        return binding.root
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
        viewModel = ViewModelProvider(this)[BlankViewModel::class.java]
        lifecycle.addObserver(viewModel)
    }


    override fun onDestroy() {
        super.onDestroy()
    }

}